﻿<%@ Page Language="C#" title="效益费用分析" MasterPageFile="~/W_View/PageMaster.Master" CodeBehind="CostbenefitPage.aspx.cs" Inherits="STHPMS1.Web.W_View.Decision.Preventive.CostbenefitPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/datagrid.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/dropdown.js")%>
    <%= UiHelper.RefJsFileHtml("/Scripts/Jquery/ajaxfileupload.js")%>

    <script type="text/javascript">

        function B_RoadwayEdit(flag) {
            var row = $('#dg').datagrid('getSelected');
            var title = "";
            if (flag == 0) {
                if (!row) {
                    $.messager.alert('消息提示', '编辑数据时，请选择一项!', 'warning');
                    return;
                }
                $('#fm').form('load', row);
                title = "新增测试数据";
            }
            else {
                $('#fm').form('clear');
                title = "编辑测试数据";
            }

            $('#dlg').dialog('open');
        }

        function B_RoadwayDel() {
            var row = $('#dg').datagrid('getSelected');
            if (!row) {
                $.messager.alert('消息提示', '删除数据时，请选择一项!', 'warning');
                return;
            }

            deleteData($('#dg'), $('#dlg'), "/api/roadway");
        }

        //计算效益费用比
        function SetBcr() {
            var anniname = $('#cmbAnniName').combobox("getValue");
            var analy_year = $('#cmbAnaly_Year').combobox("getValue");
            if (!anniname && !analy_year) {
                $.messager.alert('消息提示', '请选择资金模型名称和分析年度！', 'warning');
                return;
            }

            $.ajax({
                url: "/api/costbenefit/seetbcr?anniname=" + anniname + "&analy_year=" + analy_year + "",
                type: "GET",
                success: function () {
                    $.messager.alert('成功', '计算效益费用比!', "info");
                    $('#dg').datagrid({ url: '/api/costbenefit', pageNumber: 1 });
                },
                error: function (err) {
                    $.messager.alert('错误提示', '计算效益费用比失败 -' + err, "error");
                }
            });
        }


        function search(n, o) {
            var anniname = $('#cmbAnniName').combobox("getValue");
            var analy_year = $('#cmbAnaly_Year').combobox("getValue");

            

            var url = '/api/costbenefit';
            var urlParam = "";
            if (anniname != "" && anniname != "0") urlParam += "anniname=" + encodeURI(anniname) + "&";
            if (analy_year != "" && analy_year != "0") urlParam += "analy_year=" + encodeURI(analy_year) + "&";
            if (urlParam != "") {
                urlParam = "?" + urlParam.substring(0, urlParam.length - 1);
                url = url + urlParam;
            }

            $('#dg').datagrid({ url: url, pageNumber: 1 });
        }


        $(function () {
            var number = '<%= Page.RouteData.Values["page"] %>';
            var size = '<%= Page.RouteData.Values["size"] %>';
            
            loadAdmDiv();
            dataGridBind($('#dg'), '/api/costbenefit', '预养时机确定', $('#tb'), number, size);
            //dataGridBind($('#dg'), '', '预养时机确定', $('#tb'), number, size);

            $('.validatebox-text').bind('blur', function () {
                $(this).validatebox('enableValidation').validatebox('validate');
            });
        })

    </script>    

    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table id="dg" class="easyui-datagrid content-place"  ajaxCached="false"  >
        <thead>
            <th data-options="field:'Id',editor:'text',width:80,align:'right',hidden:true">ID</th>
            <th data-options="field:'Analy_Year',editor:'text',width:100,align:'right' ">分析年度</th>
            <th data-options="field:'Rdwayid',editor:'text',width:80,align:'right' ">路线编号</th>
            <th data-options="field:'Mainsegid',editor:'text',width:300,align:'right' ">养护路段</th>
            <th data-options="field:'Recomm_Prog',editor:'numberbox',width:150,align:'right' " >推荐方案</th>
            <th data-options="field:'Pmb',editor:'numberbox',width:120,align:'right' "formatter="formatNumber" >预防性养护效益</th>
            <th data-options="field:'Pbi',editor:'numberbox',width:120,align:'right' " formatter="formatNumber">预防性养护效益指数</th>
            <th data-options="field:'Present_Cost',editor:'text',width:130,align:'right' " formatter="formatNumber">养护费用现值/百万元 </th>
            <th data-options="field:'Euac',editor:'text',width:130,align:'right' " formatter="formatNumber">当量平均费用/百万元</th>
            <th data-options="field:'Bcr',editor:'text',width:100,align:'right' " formatter="formatNumber">效益费用比</th>
            <th data-options="field:'Main_Year',editor:'text',width:80,align:'right' ">养护年份</th>

        </thead>
    </table>
   
    <div id="tb">
        <%-- <select id="cmbRoads" class="easyui-combobox" panelHeight="80" style="width:100px" data-options="prompt:'路线编号',url:'/api/roadway/dict',method:'get',valueField:'id',textField:'id',onChange:search">
         </select>--%>

       <%-- <select id="cmbRoadnetId" class="easyui-combobox" panelHeight="80" style="width:100px" data-options="prompt:'路网名称',url:'/api/roadnet/getroadnet',method:'get',valueField:'id',textField:'text'">
         </select>--%>

         <select id="cmbAnniName" class="easyui-combobox" panelHeight="80" style="width:100px" data-options="prompt:'资金模型名称',url:'/api/dfcostmodpara/anniname',method:'get',valueField:'id',textField:'id'">
         </select>


         <select id="cmbAnaly_Year" class="easyui-combobox" name="cmbAnaly_Year" data-options="prompt:'分析年度',onChange:search" style="width:100px;">   
            <option value="2015">2015年</option>   
            <option value="2016">2016年</option>   
            <option value="2017">2017年</option>   
            <option value="2018">2018年</option>   
            <option value="2019">2019年</option>   
        </select>  
        <%--<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="B_RoadwayEdit(0)">设置养护年份</a>--%>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="SetBcr()">计算效益费用比</a>
    </div>


    
    <div id="dlg" class="easyui-dialog" title="保存数据" style="width:500px;height:300px;padding:10px" closed="true"  data-options="
				iconCls: 'icon-save',
				buttons: '#dlg-buttons'">
        <form id="fm" method="post" action="/api/costbenefit">
            <table>		
                 <tr style="display:none">
                    <td>ID:</td>
                    <td><input name='Id' class='easyui-validatebox easyui-textbox'  /></td>
                </tr>	     
                <tr>
                    <td>路线编号:</td>
                    <td><input name='Rdwayid' class='easyui-validatebox  easyui-textbox'  data-options="readonly:true"/></td>
                </tr>
                <tr>
                    <td>养护路段:</td>
                    <td><input name='Mainsegid' class='easyui-validatebox easyui-textbox'  data-options="readonly:true"/></td>
                </tr>

                
                <tr>
                    <td>推荐方案:</td>
                    <td><input name='Recomm_Prog' class='easyui-validatebox easyui-textbox' data-options="readonly:true" /></td>
                </tr>
                <tr>
                    <td>养护年份:</td>
                    <td><input name='Main_Year' class='easyui-validatebox easyui-numberbox' data-options="required:true,min:2000,max:3000"/></td>
                </tr>
               
		    </table>
        </form>
    </div>

     <div id="dlg-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:sumbitData($('#dg'),$('#dlg'))">保存</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#dlg').dialog('close')">取消</a>
	</div>
    

    
</asp:Content>

